import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import * as https from 'https';
import * as fs from 'fs';

async function bootstrap() {
  const app = await NestFactory.create(AppModule, {
    httpsOptions: {
      key: fs.readFileSync('/etc/letsencrypt/live/www.mybabyname.cn/privkey.pem'),
      cert: fs.readFileSync('/etc/letsencrypt/live/www.mybabyname.cn/fullchain.pem'),
    },
  });
  // 启用CORS
  app.enableCors({
    origin: 'https://www.mybabyname.cn',  // 可以是具体的URL或者一个函数来动态决定origin
    methods: ['GET','HEAD','PUT','PATCH','POST','DELETE','OPTIONS'],
    credentials: true,  // 是否允许发送cookie
    allowedHeaders: ['Content-Type', 'Accept', 'Authorization'], // 需要支持的请求头
  })
  await app.listen(5000);
}
bootstrap();
